<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%> 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<body>
<h1>评论管理</h1> 
<a href="${pageContext.request.contextPath}/admin">返回管理</a>
<hr />
<table width="482" height="196" border="1">
<c:forEach items="${comments}" var="comt">
  <tbody>
  <tr>
    <td>文章：<a href="${pageContext.request.contextPath}/admin/blogs/${comt.article.id }/edit">${comt.article.title }</a></td>
    <td>来自:<a href="${comt.url }">${comt.author }</a></td>
  </tr>
  <tr>
    <td colspan="2">内容：${ comt.content}  </td>
    </tr>
  <tr>
    <td colspan="2">
   <a href="${pageContext.request.contextPath}/admin/comments/${comt.id }/approved" onclick="if (confirm('设置批准？')) { var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;var m = document.createElement('input'); m.setAttribute('type', 'hidden'); m.setAttribute('name', 'method'); m.setAttribute('value', 'setApproveState'); f.appendChild(m);f.submit(); };return false;" title="批准"
      >批准</a>
        <a href="${pageContext.request.contextPath}/admin/comments/${comt.id }/unapprove" onclick="if (confirm('设置驳回？')) { var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;var m = document.createElement('input'); m.setAttribute('type', 'hidden'); m.setAttribute('name', 'method'); m.setAttribute('value', 'setApproveState'); f.appendChild(m);f.submit(); };return false;" title="驳回"
      >驳回</a> 
    &nbsp;&nbsp;<a href="#">回复</a>&nbsp;&nbsp;
<a href="${pageContext.request.contextPath}/admin/comments/${comt.id }" onclick="if (confirm('你确定要删除这篇评论吗？')) { var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;var m = document.createElement('input'); m.setAttribute('type', 'hidden'); m.setAttribute('name', 'method'); m.setAttribute('value', 'delete'); f.appendChild(m);f.submit(); };return false;" title="删除"
      >删除</a>
</td>
  </tr>
  </tbody>
  </c:forEach>
</table>
   <!-- 页码导航 -->
          <c:if test="${pages>1}">
          <div class='Nav'>
          <span>Pages (${pages}):</span>
          <c:if test="${nav[0]!=0}">
          <a href="${pageContext.request.contextPath}/admin/comments/?page=${nav[0]}"><strong>&laquo;</strong></a>
          </c:if>
          <!-- 设置导航数组长度 -->
         <c:set var="navlen" value="${fn:length(nav)}"></c:set>
         <c:forEach items="${nav}" var="lab" begin="1" end="${navlen-2}" step="1">
         	
         	<c:if test="${lab!=0}">
         		<c:choose>
         			<c:when test="${curPage==lab}">
         			 <strong class='on'>${curPage}</strong> 
         			</c:when>
         			<c:otherwise>
         			<a href="${pageContext.request.contextPath}/admin/comments/?page=${lab}">${lab }</a> 
         			</c:otherwise>
         		</c:choose>
         	</c:if>
         </c:forEach>
         
       		 <c:if test="${nav[navlen-1]!=0}">
          <a href="${pageContext.request.contextPath}/admin/comments/?page=${nav[navlen-1]}"><strong>&raquo;</strong></a>
          </c:if>
           </div>
            </c:if>
             <!-- 导航结束 -->
</body>
</html>


